/*
 *  D.cxx
 *
 * 	Author : Pallab
 * 	Created on: 12:54:15 PM - 2012:12:18
 * 	"I have not failed, I have just found 10000 ways that won't work."
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <numeric>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )
#define fo(i1,ed) foR( i1 , 0 , ed )
#define foE(i1,st,ed) foR( i1, st, ed+1 )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )
#define line puts("")

inline void wait ( double seconds ) {
    double endtime = clock() + ( seconds * CLOCKS_PER_SEC );
    while ( clock() < endtime ) {
        ;
    }
}
template<class T>
    inline T fastIn() {
    register char c=0;
    register T a=0;
    bool neg=false;
    while ( c<33 ) c=getchar();
    while ( c>33 ) {
        if ( c=='-' ) {
            neg=true;
        } else {
            a= ( a*10 ) + ( c-'0' );
        }
        c=getchar();
    }
    return neg?-a:a;
}
Int N,R,C,need;
inline void read() {
    N=fastIn<Int>(),R=fastIn<Int>(),C=fastIn<Int>(),need=fastIn<Int>();
}
inline Int solve ( Int r, Int c, Int sec ) {
    if ( sec==0LL || ( r*c ) ==0LL ) return 0LL;
    if ( r+c<=sec ) return r*c; //sqaure

    Int retval=0LL;
    //triangles
    //1:
    retval = ( ( ( sec+1LL ) *sec ) /2LL ) ;
    //2:
    if ( sec>r ) retval-= ( ( ( ( sec-r ) +1 ) * ( sec-r ) ) /2 );
    if ( sec>c ) retval-= ( ( ( ( sec-c ) +1 ) * ( sec-c ) ) /2 );
    return retval;
}
inline bool OK ( Int sec ) {
    //1:
    Int a=solve ( R-1,C,sec );
    //2:
    Int b=solve ( R,N-C,sec );
    //3:
    Int c=solve ( ( N-R ) +1,C-1,sec );
    //4:
    Int d=solve ( N-R, ( N-C ) +1,sec );

    return a+b+c+d+ ( 1LL ) >=need ? true : false;
}
inline void proc() {
    Int lo=0,hi= ( Int ) ( 1e20 );
    Int bst=hi;
    int itr=0;
    while ( itr++<300 ) {
        if ( lo==hi ) break;
        Int mid= ( lo+hi ) /2;
        if ( OK ( mid ) ) {
            hi=mid;
            bst=min ( bst,hi );
        } else {
            lo=mid;
        }
    }
    cout<<bst<<"\n";
}
int main() {
    int kase = 1;
#if defined( xerxes_pc )
    if ( !freopen ( "in1", "r", stdin ) )
        puts ( "error opening file in " ), assert ( 0 );
    kase = 1;
#endif

    fo ( i,kase ) {
        read();
        proc();
    }
    return 0;
}
// kate: indent-mode cstyle; indent-width 4; replace-tabs on;

